# Copyright 2022 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_library")

package(
    default_visibility = ["//visibility:public"],
    features = ["layering_check"],
    licenses = ["notice"],  # Apache 2.0
)

iree_compiler_cc_library(
    name = "CompilerDriver",
    srcs = [
        "CompilerDriver.cpp",
        "Diagnostics.cpp",
    ],
    hdrs = [
        "Diagnostics.h",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/ConstEval",
        "//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
        "//compiler/src/iree/compiler/Dialect/VM/Target/Bytecode",
        "//compiler/src/iree/compiler/Dialect/VM/Target/C",
        "//compiler/src/iree/compiler/Pipelines",
        "//compiler/src/iree/compiler/PluginAPI",
        "//compiler/src/iree/compiler/PluginAPI:PluginManager",
        "//compiler/src/iree/compiler/Tools:init_llvmir_translations",
        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
        "//compiler/src/iree/compiler/Tools:version",
        "//compiler/src/iree/compiler/Utils",
        "@llvm-project//llvm:Support",
        "@llvm-project//mlir:BuiltinToLLVMIRTranslation",
        "@llvm-project//mlir:BytecodeWriter",
        "@llvm-project//mlir:CAPIIR",
        "@llvm-project//mlir:Debug",
        "@llvm-project//mlir:IR",
        "@llvm-project//mlir:Parser",
        "@llvm-project//mlir:Support",
    ],
)

iree_compiler_cc_library(
    name = "IREECompileToolEntryPoint",
    srcs = [
        "IREECompileToolEntryPoint.cpp",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/Tools:iree_compile_lib",
    ],
)

iree_compiler_cc_library(
    name = "IREEMLIRLSPServerToolEntryPoint",
    srcs = [
        "IREEMLIRLSPServerToolEntryPoint.cpp",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
        "@llvm-project//mlir:IR",
        "@llvm-project//mlir:MlirLspServerLib",
        "@llvm-project//mlir:Support",
    ],
)

iree_compiler_cc_library(
    name = "IREEOptToolEntryPoint",
    srcs = [
        "IREEOptToolEntryPoint.cpp",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/Dialect/HAL/Target",
        "//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
        "//compiler/src/iree/compiler/PluginAPI:PluginManager",
        "//compiler/src/iree/compiler/Tools:init_llvmir_translations",
        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
        "@llvm-project//llvm:Support",
        "@llvm-project//mlir:Debug",
        "@llvm-project//mlir:IR",
        "@llvm-project//mlir:MlirOptLib",
        "@llvm-project//mlir:Pass",
        "@llvm-project//mlir:Support",
    ],
)

iree_compiler_cc_library(
    name = "LLDToolEntryPoint",
    srcs = [
        "LLDToolEntryPoint.cpp",
    ],
    # Special cased on the CMake side since we have to conditionally compile
    # based on whether lld is enabled.
    tags = ["skip-bazel_to_cmake"],
    deps = [
        "//compiler/bindings/c:headers",
        "@llvm-project//lld:COFF",
        "@llvm-project//lld:Common",
        "@llvm-project//lld:ELF",
        "@llvm-project//lld:MachO",
        "@llvm-project//lld:Wasm",
        "@llvm-project//llvm:Support",
        "@llvm-project//llvm:TargetParser",
    ],
)

iree_compiler_cc_library(
    name = "IREEReduceToolEntryPoint",
    srcs = [
        "IREEReduceToolEntryPoint.cpp",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/Reducer:iree_reduce_lib",
        "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
        "@llvm-project//llvm:Support",
        "@llvm-project//mlir:BytecodeWriter",
        "@llvm-project//mlir:IR",
        "@llvm-project//mlir:Parser",
        "@llvm-project//mlir:Pass",
        "@llvm-project//mlir:Support",
    ],
)

iree_compiler_cc_library(
    name = "IREECodegenDialectCAPI",
    srcs = [
        "IREECodegenDialectCAPI.cpp",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR:IREECodegenDialect",
        "//compiler/src/iree/compiler/Codegen/Utils",
        "@llvm-project//mlir:CAPIIR",
        "@llvm-project//mlir:CAPIIRHeaders",
        "@llvm-project//mlir:IR",
    ],
)

iree_compiler_cc_library(
    name = "IREEGPUDialectCAPI",
    srcs = [
        "IREEGPUDialectCAPI.cpp",
    ],
    deps = [
        "//compiler/bindings/c:headers",
        "//compiler/src/iree/compiler/Codegen/Dialect/GPU/IR:IREEGPUDialect",
        "@llvm-project//mlir:CAPIIR",
        "@llvm-project//mlir:CAPIIRHeaders",
        "@llvm-project//mlir:IR",
    ],
)
